# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=wmi-client
_pkgname="${pkgname/-*/}"
pkgver=1.3.16
pkgrel=4
pkgdesc="DCOM/WMI client implementation"
url="https://www.orvant.com/packages"
arch="all !aarch64"
license="GPL-3.0"
subpackages="libwmiclient-dev:libdev libwmiclient:lib"
makedepends="autoconf python3-dev perl-datetime"
source="https://launchpad.net/~cybersec/+archive/ubuntu/chaos-ppa-v2/+files/${_pkgname}_$pkgver.orig.tar.bz2
	openvas-wmi-1.3.16.patch
	samba-pidl.patch
	pyinclude.patch
	perl-support.patch
	musl-header-fix.patch
	gnumakefile.patch
	adapt-to-gnutls-3.x.patch"

builddir="$srcdir/$_pkgname-$pkgver"

prepare() {
	default_prepare
	update_config_guess
	update_config_sub
}

build() {
	make build "CPP=gcc -E -ffreestanding" PYTHON=python3
}

package() {
	cd Samba/source
	mkdir -p "$pkgdir"/usr/lib
	local _bins="wmic winexe"
	for bins in $_bins; do
		install -Dm755 bin/$bins "$pkgdir"/usr/bin/$bins
	done
	sh ./install-libwmiclient.sh "$pkgdir"/usr
}

libdev() {
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/pkgconfig "$subpkgdir"/usr/lib
}

lib() {
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr
}

sha512sums="cd5ccf23dff59dd599ae23b4cd8d0d68f42775b2afad8e05add04d0d4054cbb8e33655323b1d87795f23a71b6c0c0e260e38f53349c77618d2421862d172a508  wmi_1.3.16.orig.tar.bz2
be7ac5248336e5f308c23a4df7d41f061de6397855b376070f8d2c987187fe9e5bdfe5d61f9e21cf8480774c66be2581c8752627d7cbf5588be2223a91239d90  openvas-wmi-1.3.16.patch
cc0bbeb6805bb38898ced7956ed313c6cf67c11316eb2906a353fc227d1dc538fc8ce689035fee865f42e7bd13d4f74b5f12b925399f64cb22ea110da4ae9f9a  samba-pidl.patch
5d2073fe0313e92c10fdaee7fd65d2d26e1a2ac1ec70955b2009c8aaad33a4944a2a8f354d416ac346cc0c43b04b1ffe95ee012cd77ddb74a7459d67f44aec4b  pyinclude.patch
74f1172cf3d5297ea9be473acf0fcdaeb3e199b9922054eea427999ab571400c1817f3734a385d9c85f4dfad3a85e57ff1970df2c023e972fb6985dec8a9dbae  perl-support.patch
bf85fbd199398c10e389fda03a6d791633c0ebc798af5ecfe66f9d5ec519b01bd0518e42da6cf88d8d47bce196bb1ce2a561c8a77e6fca8e99f38552b7a47459  musl-header-fix.patch
afb2713a33d73c51cf4444be53e909cfa86f930dce317d4f8047fc15ad2ec2b2f8835a8cc231cd9450ffe11439483fe095f9b48ce4426cdcfbc6db3c314c11f7  gnumakefile.patch
3a370702dafeeebfbf0720063808a310f77b1eb1a48d0b7c55ebff56597f4264d934413bfa96df70b3118a8e4678eba292e22c234df700e7992b50acc2831203  adapt-to-gnutls-3.x.patch"
